<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        function delay(ms) {
            // 你的代码
            return new Promise((resolve, reject) => {
                setTimeout(() => {
                    resolve();
                }, ms)
            })
        }

        delay(3000).then(() => console.log('runs after 3 seconds'));
    </script>
</body>

</html>